<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>JAVA线程池学习日记1 | Unknown Blog</title><meta name="author" content="Ris Pika"><meta name="copyright" content="Ris Pika"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="1.池化技术线程池–&gt;为了优化资源的使用而出现的技术 为什么? -&gt; 因为不断的创建线程和摧毁线程会十分浪费资源,而线程池就是解决线程频繁创建销毁而诞生的 线程池流程-&gt;预先创建数线程,使用者可以直接到线程池中获取线程,使用结束后将线程还到线程池的方式来代替摧毁线程池 2.线程的好处 降低资源消耗 提高响应速度 方便管理  -&gt;线程复用&lt;- 3.阿里巴巴对于线程池的要">
<meta property="og:type" content="article">
<meta property="og:title" content="JAVA线程池学习日记1">
<meta property="og:url" content="https://unkonwn.online/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/index.html">
<meta property="og:site_name" content="Unknown Blog">
<meta property="og:description" content="1.池化技术线程池–&gt;为了优化资源的使用而出现的技术 为什么? -&gt; 因为不断的创建线程和摧毁线程会十分浪费资源,而线程池就是解决线程频繁创建销毁而诞生的 线程池流程-&gt;预先创建数线程,使用者可以直接到线程池中获取线程,使用结束后将线程还到线程池的方式来代替摧毁线程池 2.线程的好处 降低资源消耗 提高响应速度 方便管理  -&gt;线程复用&lt;- 3.阿里巴巴对于线程池的要">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://pic.unkonwn.online//wallhaven-x6ewo3.jpg?imageView/1/w/500/h/500">
<meta property="article:published_time" content="2023-02-28T10:02:52.000Z">
<meta property="article:modified_time" content="2023-03-01T10:54:01.244Z">
<meta property="article:author" content="Ris Pika">
<meta property="article:tag" content="java">
<meta property="article:tag" content="thread">
<meta property="article:tag" content="线程池">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic.unkonwn.online//wallhaven-x6ewo3.jpg?imageView/1/w/500/h/500"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://unkonwn.online/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/node-snackbar/0.1.16/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","languages":{"hits_empty":"We didn't find any results for the search: ${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"Traditional Chinese Activated Manually","cht_to_chs":"Simplified Chinese Activated Manually","day_to_night":"Dark Mode Activated Manually","night_to_day":"Light Mode Activated Manually","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'JAVA线程池学习日记1',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-03-01 18:54:01'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">Loading...</div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (false) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="http://pic.unkonwn.online//20140802211120_t34dW.jpeg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">6</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">13</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/upadte/"><i class="fa-fw fa fa-bell"></i><span> 日志</span></a></div><div class="menus_item"><a class="site-page" href="/myself/"><i class="fa-fw fa fa-id-card"></i><span> Myself</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 菜单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/%E5%85%B3%E4%BA%8E"><i class="fa-fw /about/"></i><span> 0</span></a></li><li><a class="site-page child" href="/butterfly%E4%B8%BB%E9%A2%98"><i class="fa-fw https://github.com/jerryc127/hexo-theme-butterfly/"></i><span> 1</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://pic.unkonwn.online//wallhaven-x6ewo3.jpg')"><nav id="nav"><span id="blog-info"><a href="/" title="Unknown Blog"><span class="site-name">Unknown Blog</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> Search</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/upadte/"><i class="fa-fw fa fa-bell"></i><span> 日志</span></a></div><div class="menus_item"><a class="site-page" href="/myself/"><i class="fa-fw fa fa-id-card"></i><span> Myself</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 菜单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/%E5%85%B3%E4%BA%8E"><i class="fa-fw /about/"></i><span> 0</span></a></li><li><a class="site-page child" href="/butterfly%E4%B8%BB%E9%A2%98"><i class="fa-fw https://github.com/jerryc127/hexo-theme-butterfly/"></i><span> 1</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">JAVA线程池学习日记1</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2023-02-28T10:02:52.000Z" title="Created 2023-02-28 18:02:52">2023-02-28</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2023-03-01T10:54:01.244Z" title="Updated 2023-03-01 18:54:01">2023-03-01</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="JAVA线程池学习日记1"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="1-池化技术"><a href="#1-池化技术" class="headerlink" title="1.池化技术"></a>1.池化技术</h2><p><strong>线程池–&gt;为了优化资源的使用而出现的技术</strong></p>
<p><strong>为什么? -&gt; 因为不断的创建线程和摧毁线程会十分浪费资源,而线程池就是解决线程频繁创建销毁而诞生的</strong></p>
<p><strong>线程池流程-&gt;预先创建数线程,使用者可以直接到线程池中获取线程,使用结束后将线程还到线程池的方式来代替摧毁线程池</strong></p>
<h2 id="2-线程的好处"><a href="#2-线程的好处" class="headerlink" title="2.线程的好处"></a>2.线程的好处</h2><ol>
<li><strong>降低资源消耗</strong></li>
<li><strong>提高响应速度</strong></li>
<li><strong>方便管理</strong></li>
</ol>
<p><em><strong>-&gt;线程复用&lt;-</strong></em></p>
<h2 id="3-阿里巴巴对于线程池的要求"><a href="#3-阿里巴巴对于线程池的要求" class="headerlink" title="3.阿里巴巴对于线程池的要求"></a>3.阿里巴巴对于线程池的要求</h2><p><strong>-&gt; 不要使用<code>executors</code>工具类创建线程池</strong></p>
<h3 id="gt-不使用java自带工具类创建线程池的原因"><a href="#gt-不使用java自带工具类创建线程池的原因" class="headerlink" title="-&gt; 不使用java自带工具类创建线程池的原因"></a>-&gt; 不使用java自带工具类创建线程池的原因</h3><ul>
<li><strong><code>FixedThreadPool </code>和 <code>singleThreadPool</code>:</strong></li>
</ul>
<p><em><strong>-&gt;允许的请求队列长度为 <code>Integer.NAX_VALUE</code>，可能会堆积大量的请求，从而导致<code>OOM</code>。</strong></em></p>
<ul>
<li><strong><code>CachedThreadPool </code>和 <code>scheduledThreadPooL</code>:</strong></li>
</ul>
<p><em><strong>-&gt;允许的创建线程数量为 <code>Integer.MAX_VALUE</code>，可能会创建大量的线程，从而导致<code>OOM</code>。</strong></em></p>
<h3 id="gt-Executors类"><a href="#gt-Executors类" class="headerlink" title="-&gt; Executors类"></a>-&gt; <code>Executors</code>类</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line">Executors.newCachedThreadPool(); <span class="comment">//无线线程池 -&gt; 有多少任务,就有多少线程</span></span><br><span class="line">Executors.newFixedThreadPool(<span class="number">10</span>); <span class="comment">//10线程 线程池 -&gt; 创建一个固定大小的线程池</span></span><br><span class="line">Executors.newSingleThreadExecutor(); <span class="comment">//单线程 线程池</span></span><br></pre></td></tr></table></figure>

<h4 id="1-newCachedThreadPool"><a href="#1-newCachedThreadPool" class="headerlink" title="1.newCachedThreadPool"></a><strong>1.<code>newCachedThreadPool</code></strong></h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> ExecutorService <span class="title function_">newCachedThreadPool</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(<span class="number">0</span>, Integer.MAX_VALUE, <span class="comment">// 易造成OOM</span></span><br><span class="line">                                  <span class="number">60L</span>, TimeUnit.SECONDS,</span><br><span class="line">                                  <span class="keyword">new</span> <span class="title class_">SynchronousQueue</span>&lt;Runnable&gt;());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="2-newFixedThreadPool"><a href="#2-newFixedThreadPool" class="headerlink" title="2.newFixedThreadPool"></a><strong>2.<code>newFixedThreadPool</code></strong></h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> ExecutorService <span class="title function_">newFixedThreadPool</span><span class="params">(<span class="type">int</span> nThreads)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(nThreads, nThreads,</span><br><span class="line">                                  <span class="number">0L</span>, TimeUnit.MILLISECONDS,</span><br><span class="line">                                  <span class="keyword">new</span> <span class="title class_">LinkedBlockingQueue</span>&lt;Runnable&gt;());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="3-newSingleThreadExecutor"><a href="#3-newSingleThreadExecutor" class="headerlink" title="3.newSingleThreadExecutor"></a><strong>3.<code>newSingleThreadExecutor</code></strong></h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> ExecutorService <span class="title function_">newSingleThreadExecutor</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">FinalizableDelegatedExecutorService</span></span><br><span class="line">        (<span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(<span class="number">1</span>, <span class="number">1</span>,</span><br><span class="line">                                <span class="number">0L</span>, TimeUnit.MILLISECONDS,</span><br><span class="line">                                <span class="keyword">new</span> <span class="title class_">LinkedBlockingQueue</span>&lt;Runnable&gt;()));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="gt-以上线程池本质就是-ThreadPoolExecutor"><a href="#gt-以上线程池本质就是-ThreadPoolExecutor" class="headerlink" title="**-&gt; 以上线程池本质就是 **ThreadPoolExecutor"></a>**-&gt; 以上线程池本质就是 **<code>ThreadPoolExecutor</code></h4><h2 id="4-ThreadPoolExecutor源码分析-7个参数"><a href="#4-ThreadPoolExecutor源码分析-7个参数" class="headerlink" title="4.ThreadPoolExecutor源码分析(7个参数)"></a>4.<code>ThreadPoolExecutor</code>源码分析(7个参数)</h2><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="title function_">ThreadPoolExecutor</span><span class="params">(<span class="type">int</span> corePoolSize, // 核心线程池大小</span></span><br><span class="line"><span class="params">                          <span class="type">int</span> maximumPoolSize, // 最大核心线程池大小</span></span><br><span class="line"><span class="params">                          <span class="type">long</span> keepAliveTime, // 超时时间-&gt;超出时间释放</span></span><br><span class="line"><span class="params">                          TimeUnit unit, // 超时单位</span></span><br><span class="line"><span class="params">                          BlockingQueue&lt;Runnable&gt; workQueue,  // 阻塞队列</span></span><br><span class="line"><span class="params">                          ThreadFactory threadFactory, // 线程工厂-&gt;创建线程</span></span><br><span class="line"><span class="params">                          RejectedExecutionHandler handler)</span> &#123; <span class="comment">// 拒绝策略 </span></span><br><span class="line">    <span class="keyword">if</span> (corePoolSize &lt; <span class="number">0</span> ||</span><br><span class="line">        maximumPoolSize &lt;= <span class="number">0</span> ||</span><br><span class="line">        maximumPoolSize &lt; corePoolSize ||</span><br><span class="line">        keepAliveTime &lt; <span class="number">0</span>)</span><br><span class="line">        <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">IllegalArgumentException</span>();</span><br><span class="line">    <span class="keyword">if</span> (workQueue == <span class="literal">null</span> || threadFactory == <span class="literal">null</span> || handler == <span class="literal">null</span>)</span><br><span class="line">        <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">NullPointerException</span>();</span><br><span class="line">    <span class="built_in">this</span>.acc = System.getSecurityManager() == <span class="literal">null</span> ?</span><br><span class="line">            <span class="literal">null</span> :</span><br><span class="line">            AccessController.getContext();</span><br><span class="line">    <span class="built_in">this</span>.corePoolSize = corePoolSize;</span><br><span class="line">    <span class="built_in">this</span>.maximumPoolSize = maximumPoolSize;</span><br><span class="line">    <span class="built_in">this</span>.workQueue = workQueue;</span><br><span class="line">    <span class="built_in">this</span>.keepAliveTime = unit.toNanos(keepAliveTime);</span><br><span class="line">    <span class="built_in">this</span>.threadFactory = threadFactory;</span><br><span class="line">    <span class="built_in">this</span>.handler = handler;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="gt-图解分析"><a href="#gt-图解分析" class="headerlink" title="-&gt;图解分析"></a><em><strong>-&gt;图解分析</strong></em></h4><p><img src= "" data-lazy-src="https://pic.unkonwn.online//20230228163231.png"></p>
<p><strong>第一个参数<code>corePoolSize</code>-&gt; 就是Core 核心人员,当核心人员未在处理任务时,客户既可以进入业务</strong></p>
<p><strong>第五个参数<code>workQueue</code>-&gt; 阻塞队列,客户当核心人员都在处理业务时,可以再此(候客区)进行等待</strong></p>
<p><strong>第二个参数<code>maximumPoolSize</code>-&gt; 当客户数量超过了核心人数和候客区最大承载量-&gt;即会开辟新的处理区进行处理-&gt;使核心人员和其他人员人数为<code>maximumPoolSize</code></strong></p>
<p><strong>第七个参数<code>handler </code>-&gt; 银行满了,上面的各种情况都满足最大值后,触发拒绝策略 -&gt; 抛出异常等实现方法(可控制)</strong></p>
<h4 id="gt-代码证明"><a href="#gt-代码证明" class="headerlink" title="-&gt;代码证明"></a><em><strong>-&gt;代码证明</strong></em></h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">    <span class="type">ThreadPoolExecutor</span> <span class="variable">threadPoolExecutor</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(<span class="number">2</span>,</span><br><span class="line">            <span class="number">5</span>,</span><br><span class="line">            <span class="number">3</span>,</span><br><span class="line">            TimeUnit.SECONDS,</span><br><span class="line">            <span class="keyword">new</span> <span class="title class_">LinkedBlockingQueue</span>&lt;&gt;(<span class="number">3</span>),</span><br><span class="line">            Executors.defaultThreadFactory(),</span><br><span class="line">            <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.AbortPolicy());</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i &lt; <span class="number">5</span>; i++) &#123;</span><br><span class="line">        threadPoolExecutor.execute(()-&gt;&#123;</span><br><span class="line">            System.out.println(Thread.currentThread().getName()+<span class="string">&quot; ok&quot;</span>);</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 结果</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-2 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-2 ok</span></span><br><span class="line"><span class="comment"> */</span></span><br></pre></td></tr></table></figure>

<ul>
<li><p><strong>在上述代码中,创建了2个核心线程,最大并发数为5个,而阻塞队列大小为3,而本次循环并未能使用到第三个或第三个以上的线程,这是因为-&gt;核心线程和阻塞队列足够容纳5的大小,故线程池也不需要再开辟新的空间</strong></p>
</li>
<li><p><strong>假若把i的值改为8-&gt;则会出现以下结果(开辟了最大并发线程数)</strong></p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-5 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-3 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-4 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-2 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-3 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-5 ok</span></span><br><span class="line"><span class="comment"> */</span></span><br></pre></td></tr></table></figure>

<ul>
<li><strong>假若i的值超过线程池最大的承载能力，将会执行定义的拒绝策略</strong></li>
</ul>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">    <span class="type">ThreadPoolExecutor</span> <span class="variable">threadPoolExecutor</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(<span class="number">2</span>,</span><br><span class="line">            <span class="number">5</span>,</span><br><span class="line">            <span class="number">3</span>,</span><br><span class="line">            TimeUnit.SECONDS,</span><br><span class="line">            <span class="keyword">new</span> <span class="title class_">LinkedBlockingQueue</span>&lt;&gt;(<span class="number">3</span>),</span><br><span class="line">            Executors.defaultThreadFactory(),</span><br><span class="line">            <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.AbortPolicy());</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i &lt; <span class="number">9</span>; i++) &#123;</span><br><span class="line">        threadPoolExecutor.execute(()-&gt;&#123;</span><br><span class="line">            System.out.println(Thread.currentThread().getName()+<span class="string">&quot; ok&quot;</span>);</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 结果</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-3 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-4 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-2 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-5 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-3 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-1 ok</span></span><br><span class="line"><span class="comment"> * pool-1-thread-2 ok</span></span><br><span class="line"><span class="comment"> * Exception in thread &quot;main&quot; java.util.concurrent.RejectedExecutionException: Task thread.ThreadPoolExecutorDemo$$Lambda$1/793589513@34c45dca rejected from java.util.concurrent.ThreadPoolExecutor@52cc8049[Running, pool size = 5, active threads = 4, queued tasks = 2, completed tasks = 1]</span></span><br><span class="line"><span class="comment"> *     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)</span></span><br><span class="line"><span class="comment"> *     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)</span></span><br><span class="line"><span class="comment"> *     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)</span></span><br><span class="line"><span class="comment"> *     at thread.ThreadPoolExecutorDemo.main(ThreadPoolExecutorDemo.java:16)</span></span><br><span class="line"><span class="comment"> */</span></span><br></pre></td></tr></table></figure>

<h4 id="gt-四种拒绝策略"><a href="#gt-四种拒绝策略" class="headerlink" title="-&gt;四种拒绝策略"></a><em><strong>-&gt;四种拒绝策略</strong></em></h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 四种拒绝策略</span></span><br><span class="line"><span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.AbortPolicy(); <span class="comment">// 队列满了,不进行处理,直接抛出异常</span></span><br><span class="line"><span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.CallerRunsPolicy(); <span class="comment">// 哪里来,哪里回去</span></span><br><span class="line"><span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.DiscardPolicy(); <span class="comment">// 队列满了不会抛出异常</span></span><br><span class="line"><span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.DiscardOldestPolicy(); <span class="comment">// 队列满了,尝试与第一个竞争,不抛出异常</span></span><br></pre></td></tr></table></figure>

<h4 id="gt-最大线程该如何去定义"><a href="#gt-最大线程该如何去定义" class="headerlink" title="-&gt;最大线程该如何去定义"></a>-&gt;最大线程该如何去定义</h4><ol>
<li><strong>CPU密集型: 多少核心用多少线程, 可以保持CPU的效率最高!</strong></li>
</ol>
<p><strong>-&gt;获取当前机器最大核心:</strong></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">System.out.println(Runtime.getRuntime().availableProcessors());</span><br></pre></td></tr></table></figure>

<ol start="2">
<li><strong>IO密集型: 判断程序中耗费IO的线程,选用大于该线程的线程!</strong></li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="https://unkonwn.online">Ris Pika</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="https://unkonwn.online/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/">https://unkonwn.online/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/java/">java</a><a class="post-meta__tags" href="/tags/thread/">thread</a><a class="post-meta__tags" href="/tags/%E7%BA%BF%E7%A8%8B%E6%B1%A0/">线程池</a></div><div class="post_share"><div class="social-share" data-image="https://pic.unkonwn.online//wallhaven-x6ewo3.jpg?imageView/1/w/500/h/500" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://lib.baomitu.com/social-share.js/1.0.16/css/share.min.css" media="print" onload="this.media='all'"><script src="https://lib.baomitu.com/social-share.js/1.0.16/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/03/01/JUC%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JUC学习日记1"><img class="cover" src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-6dl2yw.jpg?imageView/1/w/500/h/500" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">JUC学习日记1</div></div></a></div><div class="next-post pull-right"><a href="/2023/02/27/blocking-queue/" title="初学BlockingQueue"><img class="cover" src= "" data-lazy-src="http://pic.unkonwn.online/wallhaven-we52yp.jpg?imageView/1/w/240/h/240" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">初学BlockingQueue</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>Related Articles</span></div><div class="relatedPosts-list"><div><a href="/2023/02/26/jwt/" title="五分钟JWT入门"><img class="cover" src= "" data-lazy-src="http://pic.unkonwn.online/wallhaven-qzr7pr.jpg?imageView/1/w/240/h/240" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-02-26</div><div class="title">五分钟JWT入门</div></div></a></div><div><a href="/2023/02/27/blocking-queue/" title="初学BlockingQueue"><img class="cover" src= "" data-lazy-src="http://pic.unkonwn.online/wallhaven-we52yp.jpg?imageView/1/w/240/h/240" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-02-27</div><div class="title">初学BlockingQueue</div></div></a></div><div><a href="/2023/03/01/JUC%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JUC学习日记1"><img class="cover" src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-6dl2yw.jpg?imageView/1/w/500/h/500" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-03-01</div><div class="title">JUC学习日记1</div></div></a></div><div><a href="/2023/03/01/JAVA-%E4%BB%8E0%E5%88%B0helloworld/" title="JAVA 从0到helloworld"><img class="cover" src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-gpw787.jpg?imageView/1/w/500/h/500" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-03-01</div><div class="title">JAVA 从0到helloworld</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="http://pic.unkonwn.online//20140802211120_t34dW.jpeg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Ris Pika</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">6</div></a><a href="/tags/"><div class="headline">Tags</div><div class="length-num">13</div></a><a href="/categories/"><div class="headline">Categories</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/rispika/"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>Announcement</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E6%B1%A0%E5%8C%96%E6%8A%80%E6%9C%AF"><span class="toc-number">1.</span> <span class="toc-text">1.池化技术</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%A5%BD%E5%A4%84"><span class="toc-number">2.</span> <span class="toc-text">2.线程的好处</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4%E5%AF%B9%E4%BA%8E%E7%BA%BF%E7%A8%8B%E6%B1%A0%E7%9A%84%E8%A6%81%E6%B1%82"><span class="toc-number">3.</span> <span class="toc-text">3.阿里巴巴对于线程池的要求</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#gt-%E4%B8%8D%E4%BD%BF%E7%94%A8java%E8%87%AA%E5%B8%A6%E5%B7%A5%E5%85%B7%E7%B1%BB%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E7%9A%84%E5%8E%9F%E5%9B%A0"><span class="toc-number">3.1.</span> <span class="toc-text">-&gt; 不使用java自带工具类创建线程池的原因</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#gt-Executors%E7%B1%BB"><span class="toc-number">3.2.</span> <span class="toc-text">-&gt; Executors类</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-newCachedThreadPool"><span class="toc-number">3.2.1.</span> <span class="toc-text">1.newCachedThreadPool</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-newFixedThreadPool"><span class="toc-number">3.2.2.</span> <span class="toc-text">2.newFixedThreadPool</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-newSingleThreadExecutor"><span class="toc-number">3.2.3.</span> <span class="toc-text">3.newSingleThreadExecutor</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#gt-%E4%BB%A5%E4%B8%8A%E7%BA%BF%E7%A8%8B%E6%B1%A0%E6%9C%AC%E8%B4%A8%E5%B0%B1%E6%98%AF-ThreadPoolExecutor"><span class="toc-number">3.2.4.</span> <span class="toc-text">**-&gt; 以上线程池本质就是 **ThreadPoolExecutor</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-ThreadPoolExecutor%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90-7%E4%B8%AA%E5%8F%82%E6%95%B0"><span class="toc-number">4.</span> <span class="toc-text">4.ThreadPoolExecutor源码分析(7个参数)</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#gt-%E5%9B%BE%E8%A7%A3%E5%88%86%E6%9E%90"><span class="toc-number">4.0.1.</span> <span class="toc-text">-&gt;图解分析</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#gt-%E4%BB%A3%E7%A0%81%E8%AF%81%E6%98%8E"><span class="toc-number">4.0.2.</span> <span class="toc-text">-&gt;代码证明</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#gt-%E5%9B%9B%E7%A7%8D%E6%8B%92%E7%BB%9D%E7%AD%96%E7%95%A5"><span class="toc-number">4.0.3.</span> <span class="toc-text">-&gt;四种拒绝策略</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#gt-%E6%9C%80%E5%A4%A7%E7%BA%BF%E7%A8%8B%E8%AF%A5%E5%A6%82%E4%BD%95%E5%8E%BB%E5%AE%9A%E4%B9%89"><span class="toc-number">4.0.4.</span> <span class="toc-text">-&gt;最大线程该如何去定义</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/03/01/JAVA-%E4%BB%8E0%E5%88%B0helloworld/" title="JAVA 从0到helloworld"><img src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-gpw787.jpg?imageView/1/w/500/h/500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JAVA 从0到helloworld"/></a><div class="content"><a class="title" href="/2023/03/01/JAVA-%E4%BB%8E0%E5%88%B0helloworld/" title="JAVA 从0到helloworld">JAVA 从0到helloworld</a><time datetime="2023-03-01T14:32:08.000Z" title="Created 2023-03-01 22:32:08">2023-03-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/03/01/JUC%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JUC学习日记1"><img src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-6dl2yw.jpg?imageView/1/w/500/h/500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JUC学习日记1"/></a><div class="content"><a class="title" href="/2023/03/01/JUC%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JUC学习日记1">JUC学习日记1</a><time datetime="2023-03-01T12:52:40.000Z" title="Created 2023-03-01 20:52:40">2023-03-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JAVA线程池学习日记1"><img src= "" data-lazy-src="https://pic.unkonwn.online//wallhaven-x6ewo3.jpg?imageView/1/w/500/h/500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JAVA线程池学习日记1"/></a><div class="content"><a class="title" href="/2023/02/28/JAVA%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%AD%A6%E4%B9%A0%E6%97%A5%E8%AE%B01/" title="JAVA线程池学习日记1">JAVA线程池学习日记1</a><time datetime="2023-02-28T10:02:52.000Z" title="Created 2023-02-28 18:02:52">2023-02-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/27/blocking-queue/" title="初学BlockingQueue"><img src= "" data-lazy-src="http://pic.unkonwn.online/wallhaven-we52yp.jpg?imageView/1/w/240/h/240" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="初学BlockingQueue"/></a><div class="content"><a class="title" href="/2023/02/27/blocking-queue/" title="初学BlockingQueue">初学BlockingQueue</a><time datetime="2023-02-27T07:50:33.000Z" title="Created 2023-02-27 15:50:33">2023-02-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/02/26/jwt/" title="五分钟JWT入门"><img src= "" data-lazy-src="http://pic.unkonwn.online/wallhaven-qzr7pr.jpg?imageView/1/w/240/h/240" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="五分钟JWT入门"/></a><div class="content"><a class="title" href="/2023/02/26/jwt/" title="五分钟JWT入门">五分钟JWT入门</a><time datetime="2023-02-26T13:39:36.000Z" title="Created 2023-02-26 21:39:36">2023-02-26</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Ris Pika</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">unknown!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vanilla-lazyload/17.3.1/lazyload.iife.min.js"></script><script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/node-snackbar/0.1.16/snackbar.min.js"></script><div class="js-pjax"></div><script defer src="/live2d-widget/autoload.js"></script><canvas class="fireworks" mobile="true"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">Search</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  Loading the Database</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="Search for Posts" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></body></html>